28 October 2017

R to visualize your data

Why visualize your data?


  • summarize information
  • check assumptions validity
  • many pieces of information at one glance
  • ease the understanding

Why use R to do it?

Workflow



         

Why use R to do it?

Workflow



           

Why use R to do it?

Here we'll argue why use R for doing your plots:

  • visualizing data
  • what makes a good graph (some details)
  • work-flow (data are already in R)
  • base graph / ggplot2 / web graphs (interacting)
  • code / reproducible

Why use R to do it?

Different valuable options

  • The gridGraphics package
  • base VS ggplot2
  • Web-based graphs

Why use R to do it?

Why use R to do it?

Why use R to do it?

Few lines of codes

library(raster)
library(mapview)
elvBtn = getData('alt', country='BTN', path='./assets/')
mapview(elvBtn)

Why use R to do it?

Few lines of codes

Why use R to do it?

A large community

Why use R to do it?

Common plots used in meta-analyses

What do we want/need to visualize?

Effect Size (ES)

  • log risk ratios,
  • log odds ratios,
  • …,
  • non-standard ES

Studies

  • by author
  • by region
  • by species

Effect size – Funnel plot

Effect size – Forest plot









Vellend et. al 2013

Effect size – Forest plot

Effect size – Radial plot

Effect size – L'Abbé plot

Number of Study & effect size

Vellend et al. 2013

Number of Study & geography


Vellend et al. 2013

Common plots used in meta-analyses with R

R packages for meta-analyses

  • click here kev

  • install.packages("ctv"); ctv::install.views("MetaAnalysis")

Meta vs Metafor – briefly

Meta vs Metafor – briefly

Meta vs Metafor – support

Meta – workflow

  1. meta:
    • metabin()
Arguments:

 event.e: Number of events in experimental group.
     n.e: Number of observations in experimental group.
 event.c: Number of events in control group.
     n.c: Number of observations in control group.

Meta – workflow

meta:

- `metabin()` / `metagen()`
Arguments:

      TE: Estimate of treatment effect.
    seTE: Standard error of treatment estimate.

Meta – workflow

meta:

- `metabin()` / `metagen()`
- `funnel`, `forest`, ..
install.packages('meta')
library(meta)
data(Olkin95)
# ?Olkin95
meta1 <- metabin(event.e, n.e, event.c, n.c,
                  data=Olkin95, subset=c(41,47,51,59),
                  sm="RR", method="I",
                  studlab=paste(author, year))

forest(meta1)

Meta – workflow

author year event.e n.e event.c n.c
Fletcher 1959 1 12 4 11
Dewar 1963 4 21 7 21
Lippschutz 1965 6 43 7 41
European 1 1969 20 83 15 84
European 2 1971 69 373 94 357
Heikinheimo 1971 22 219 17 207

Meta – workflow

Metafor – workflow

Metafor – workflow

  • Calculate effect size: escalc()

  • Perform analysis: rma()

  • Plots: funnel(), 'forest()', 'labbe()', …

Metafor – workflow

install.packages('metafor')
library('metafor')

Funnel plot – version 2

Funnel plot – version 3

Forest plot

Pros and Cons

Custom your plot

Which way I go?

Few tips

  • par()
  • axis()
  • Legend()
  • points()
  • lines()
  • text()
  • abline()
  • colors
  • multiplot
  • exportation

Example funnel plot

Questions?

Let's practice

Reproduce 2 figures from Vellend et al. 2013



  • Paper is available on line

  • Data available on line as well Dataset S1

Figure S2

Vellend et al. 2013

Figure 3









Extra

WordCloud

WordCloud

Network of co-authors

igraph

Resources

Useful links

That's all folks